import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
export const mainLayoutRoutes: Array<RouteRecordRaw> = [
  {
    path: "/home",
    name: "home",
    component: () =>
      import(/* webpackChunkName: "home" */ "@/views/home/homeView.vue"),
    meta: {
      title: "首页",
      icon: "home-o",
    },
  },
  {
    path: "/classify",
    name: "classify",
    component: () =>
      import(
        /* webpackChunkName: "classify" */ "@/views/classify/classifyView.vue"
      ),
    meta: {
      title: "分类",
      icon: "apps-o",
    },
  },
  {
    path: "/shop/car",
    name: "shopCar",
    component: () =>
      import(
        /* webpackChunkName: "shopCar" */ "@/views/shopCar/shopCarView.vue"
      ),
    meta: {
      title: "购物车",
      icon: "cart-o",
    },
  },
  {
    path: "/car/list",
    name: "carList",
    component: () =>
      import(
        /* webpackChunkName: "carList" */ "@/views/carList/carListView.vue"
      ),
    meta: {
      title: "选车",
      icon: "orders-o",
    },
  },
  {
    path: "/my",
    name: "my",
    component: () =>
      import(/* webpackChunkName: "my" */ "@/views/my/myView.vue"),
    meta: {
      title: "我的",
      icon: "user-o",
    },
  },
];
const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "mainLayout",
    redirect: "/home",
    component: () =>
      import(
        /* webpackChunkName: "mainLayout" */ "@/mainLayout/mainLayoutView.vue"
      ),
    children: mainLayoutRoutes,
  },
  {
    path: "/login",
    name: "login",
    component: () =>
      import(/* webpackChunkName: "login" */ "@/views/login/loginView.vue"),
  },
  {
    path: "/detail/:id",
    name: "detail",
    component: () =>
      import(/* webpackChunkName: "detail" */ "@/views/detail/detailView.vue"),
    props: true
  },
  {
    path: "/user/history",
    name: "userHistory",
    component: () =>
      import(
        /* webpackChunkName: "userHistory" */ "@/views/userHistory/userHistoryView.vue"
      ),
  },
  {
    path: "/search",
    name: "search",
    component: () =>
      import(/* webpackChunkName: "search" */ "@/views/search/searchView.vue"),
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
